import type {
  AddressItem,
  Logisitics,
  OrderDetail,
  OrderPre
} from '@/types/order'
import { request } from '@/utils/request'

// 查询药品订单预支付信息
export const getMedicalOrderPre = (params: { prescriptionId: string }) =>
  request<OrderPre>('/patient/medicine/order/pre', 'GET', params)

// 获取收货地址列表
export const getAddressList = () =>
  request<AddressItem[]>('/patient/order/address')

/**
 * @description:(根据处方)获取药品订单信息
 * @param id  处方药品id
 * @param address  地址信息
 * @param couponId  优惠券ID
 * @return id 返回支付成功后的 订单id
 * */
export const createMedicalOrder = (data: {
  id: string // 处方id
  address: string // 地址信息
  couponId?: string // 优惠券ID
}) => request<{ id: string }>('/patient/medicine/order', 'POST', data)

/**
 * @description: 获取药品订单详情信息
 * @param id 处方药品支付成功返回的订单id
 * @return res: 订单详情数据
 * */
export const getMedicalOrderDetail = (id: string) =>
  request<OrderDetail>(`/patient/medicine/order/detail/${id}`)

/**
 * @description: 订单-查询物流信息
 * @param {id} 订单id
 * */
export const getOrderLogistics = (id: string) =>
  request<Logisitics>(`/patient/order/${id}/logistics`)
